﻿using System.Runtime.CompilerServices;
namespace TowerOfHanoi
{
    internal class Program
    {       
        /// <summary>
        /// 汉诺塔小游戏
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            //接受用户输入
            Console.WriteLine("请输入一个正整数");
            int input = Convert.ToInt32(Console.ReadLine());
            Move(input,'A','B','C');    
        }
        /// <summary>
        /// 递归到n层汉诺塔
        /// </summary>
        /// <param name="n"></param>
        /// <param name="Left"></param>
        /// <param name="Middle"></param>
        /// <param name="Right"></param>
        static void Move(int n,char Left,char Middle,char Right )
        {
            if(n==1)
            {
                //若只有一层，则直接移动到中间目标柱子
                Console.WriteLine($"第{n}层圆盘从{Left}柱移动到{Middle}柱");
            }
            else
            {
                //(n-1)层移动到右侧过渡柱子
                Move(n - 1, Left, Right, Middle);
                //n层移动到中间目标柱子
                Console.WriteLine($"第{n}层圆盘从{Left}柱移动到{Middle}柱");
                //(n-1)层从右侧过渡柱子移动到中间目标柱子
                Move(n - 1, Right, Middle, Left);
            }
        }
    }
}